<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>NSPR: Network Functions</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- 制作者 Doxygen 1.5.7.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="modules.html"><span>模块</span></a></li>
      <li><a href="files.html"><span>文件</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>Network Functions<br>
<small>
[<a class="el" href="group___n_s_p_r.html">NOSEC Portable Runtime</a>]</small>
</h1>
<p>
<div class="dynheader">
Network Functions合作图：</div>
<div class="dynsection">
<center><table><tr><td><img src="group___n_s_p_r___n_e_t.png" border="0" alt="" usemap="#group______n__s__p__r______n__e__t_map">
<map name="group______n__s__p__r______n__e__t_map">
<area shape="rect" href="group___n_s_p_r.html" title="NOSEC Portable Runtime" alt="" coords="7,5,177,32"></map></td></tr></table></center>
</div>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>函数</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned long&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___n_s_p_r___n_e_t.html#g6c79cc818aa8411a709c10b0d222b381">resolv_host</a> (char *host)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned long&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___n_s_p_r___n_e_t.html#g77cf9353b74e69a8550733c87249379a">get_next_hop_to_dst</a> (char *dst)</td></tr>

</table>
<hr><a name="_details"></a><h2>详细描述</h2>
本模快封装了一些经常使用的网络函数。 <hr><h2>函数文档</h2>
<a class="anchor" name="g77cf9353b74e69a8550733c87249379a"></a><!-- doxytag: member="nspr_net.h::get_next_hop_to_dst" ref="g77cf9353b74e69a8550733c87249379a" args="(char *dst)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned long get_next_hop_to_dst           </td>
          <td>(</td>
          <td class="paramtype">char *&nbsp;</td>
          <td class="paramname"> <em>dst</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
根据指定的目标地址，获取下一条的IP地址<p>
如果目标机器在同一子网，那么下一跳就是对端IP地址；如果不在同一子网，那么下一跳就是网关的地址。<p>
<dl compact><dt><b>参数:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>dst</em>&nbsp;</td><td>目的地址，可以是域名或者IP格式 </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>返回:</b></dt><dd>非0为转换成功后的值，0表示解析失败 </dd></dl>
<dl class="note" compact><dt><b>注解:</b></dt><dd>需要使用iphlpapi头文件和库 <div class="fragment"><pre class="fragment">示例:
<span class="preprocessor">#include "iphlpapi.h"</span>
<span class="preprocessor">#pragma comment(lib,"iphlpapi")</span>
<span class="preprocessor"></span>
in_addr             ia;
ia.S_un.S_addr = <a class="code" href="group___n_s_p_r___n_e_t.html#g77cf9353b74e69a8550733c87249379a">get_next_hop_to_dst</a>(<span class="stringliteral">"192.168.1.1"</span>);
printf(<span class="stringliteral">"Next Hop IP Address is : %s\n"</span>, inet_ntoa(ia));
</pre></div> </dd></dl>

<p>
<div class="dynheader">
函数调用图:</div>
<div class="dynsection">
<p><center><img src="group___n_s_p_r___n_e_t_g77cf9353b74e69a8550733c87249379a_cgraph.png" border="0" usemap="#group___n_s_p_r___n_e_t_g77cf9353b74e69a8550733c87249379a_cgraph_map" alt=""></center>
</div>

</div>
</div><p>
<a class="anchor" name="g6c79cc818aa8411a709c10b0d222b381"></a><!-- doxytag: member="nspr_net.h::resolv_host" ref="g6c79cc818aa8411a709c10b0d222b381" args="(char *host)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned long resolv_host           </td>
          <td>(</td>
          <td class="paramtype">char *&nbsp;</td>
          <td class="paramname"> <em>host</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
将主机名或IP转换成sa.sin_addr.S_un.S_addr需要的值 <dl compact><dt><b>参数:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>host</em>&nbsp;</td><td>待解析的主机，可以是域名或者IP格式 </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>返回:</b></dt><dd>非0为转换成功后的值，0表示解析失败 <div class="fragment"><pre class="fragment">示例：
<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> dwAddr = <a class="code" href="group___n_s_p_r___n_e_t.html#g6c79cc818aa8411a709c10b0d222b381">resolv_host</a>(<span class="stringliteral">"www.nosec.org"</span>);
</pre></div> </dd></dl>

</div>
</div><p>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated at Wed Dec 3 00:17:02 2008 for NSPR by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.7.1 </small></address>
</body>
</html>
